package com.zhz.service.impl;

import com.zhz.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhz.mapper.SysMenuMapper;
import com.zhz.domain.SysMenu;
import com.zhz.service.SysMenuService;
/**
 * @author ：zhz
 * @date ：Created in 2020/12/20
 * @version: V1.0
 * @slogan: 天下风云出我辈，一入代码岁月催
 * @description: 
 **/
@Service
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService{

    @Autowired
    private SysRoleService sysRoleService;
    @Autowired
    private SysMenuMapper sysMenuMapper;
    /**
     * 通过用户的id查询用户的菜单数据
     * @param userId 用户id
     * @return
     */
    @Override
    public List<SysMenu> getMenusByUserId(long userId) {
        //1、如果用户是超级管理员-》拥有所有菜单
        if (sysRoleService.isSuperAdmin(userId)){
            return list();//查询所有
        }
        //2、如果用户不是超级管理员-》查询角色-》查询菜单
        return sysMenuMapper.selectMenusByUserId(userId);
    }
}
